Repository navigation
fix(angular): set tabs outlet before emitting ionTabsWillChange - #31814
Open
gaurav0107 wants to merge 1 commit into
Open
gaurav0107 wants to merge 1 commit into
gaurav0107 wants to merge 1 commit into
Conversation
When ion-tabs renders after the router has already activated the tab route, the inner ion-router-outlet activates the first tab while IonTabs is still in its first change detection. ionTabsWillChange then fires before the non-static `outlet` view query resolves, so handlers that read `outlet` (or call `getSelected()`) throw. Pass the `#outlet` template reference into `onStackWillChange` from both the standalone and lazy IonTabs templates and assign `outlet` before emitting. resolves ionic-team#31674
|
@gaurav0107 is attempting to deploy a commit to the Ionic Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue number: resolves #31674
What is the current behavior?
When
ion-tabsrenders after the router has already activated the tab route (for exampleion-tabsbehind an@if, or a tabs page rendered by Angular's<router-outlet>), the innerion-router-outletactivates the first tab whileIonTabsis still in its first change detection.ionTabsWillChangethen fires before the non-static@ViewChild('outlet')query has resolved, soIonTabs.outletisundefinedin that first handler. Anything that readsoutlet, or callsgetSelected(), throwsTypeError: Cannot read properties of undefined.What is the new behavior?
ion-router-outletbinding in theIonTabstemplate now passes its#outlettemplate reference intoonStackWillChange, which setsoutletbefore emittingionTabsWillChange. This is the approach suggested in the issue.IonTabsshare the same template, so both are updated./standalone/tabs-outlet-ready) that rendersion-tabsbehind an@ifthat becomes true after the tab route has activated, plus an e2e test checking thatoutletis defined on the firstionTabsWillChange.Does this introduce a breaking change?
Other information
outletisundefinedon the first event) and passes with it.npm run lint,npm run buildandnpm run testinpackages/angularpass.onStackWillChangeis@internal, and the new parameter is optional.🤖 Opened with Superhuman, an open-source contribution agent.